const {http,handleStr} = require("../../utils/http")
Page({
 data:{
     musics:[]
 },
 onLoad(){
     var url = 'http://47.108.197.28:3000/top/playlist?cat=华语'
     /* 1、发送http请求 */
     http({
        url,
        success:res=>{
          this.handleHttpData(res)
            
        }
     })
 },
 handleHttpData(res){
   var musics=[]
   var playlists=res.data.playlists;
   playlists.forEach(item=>{
                var {id,name,coverImgUrl} = item;
                musics.push({
                    id,
                    name:handleStr(name),
                    coverImgUrl
                })
            })
            this.setData({
                musics
            })
 },
 handleItem(event){ 
  var {aid}=event.currentTarget.dataset;
  wx.navigateTo({
    url: `/pages/detail/detail?id=${aid}`,
  });
 }
})
